{include file="public/header"}

		<style type="text/css">
			.mainPage .contentBoxs .centerBox{
				position: relative;
			}
			.mainPage .contentBoxs .centerBox .btns{
				font-size: 0.42rem;
			}
			.refreshBox{
				position: absolute;
				right: 0;
				bottom: 105%;
				z-index: 20;
				width: 0.9rem;
				height: 0.9rem;
				background-color: rgba(255,255,255,0.8);
				border-radius: 5px;
			}
			.refreshBox .iconBox{
				width: 0.45rem;
				height: 0.45rem;
				margin: auto;
				position: relative;
				margin-top: 0.05rem;
			}
			.refreshBox .textBox{
				font-size: 0.24rem;
				text-align: center;
				color: #caa632;
			}		
			

		</style>
		
		<div id="index">
			<div class="mainPage">
				<div class="contentBoxs">
					<div class="bgBox" :style="{minHeight: winHeight}"></div>
					<div style="position: relative;z-index: 8;">
						<div class="headGoBackBox">
							<div class="backBtn" @click="goBack">
								<div class="goBackI"><img src="/public/static/mobile/image/goBackIcon.png" style="width: 100%;"></div>
								<div class="goBackT">返回</div>
							</div>
							<div style="flex: 1;"></div>
							<div class="refresh" @click="refreshBtn">刷新</div>
						</div>
                        {include file="public/logobox"}
						<div class="centerBox">
							<!-- <div class="refreshBox" @click="refreshBtn">
								<div class="iconBox"><img src="/public/static/mobile/image/refreshIcon.png" style="width: 100%;height: 100%;position: absolute;top: 0;left: 0;"/></div>
								<div class="textBox">刷新</div>
							</div> -->
							<div class="btns " :class="activeState ? 'disable' : ''" v-on:click="activationBtn('/mobile/activation/index.html?sn='+sn+'&phone='+phone)">
								<span v-if="activeStateInfo==0">保修激活</span>	
								<span v-if="activeStateInfo==1">该设备保修已激活</span>	
								<span v-if="activeStateInfo==2">该设备保修审核中</span>	
								<span v-if="activeStateInfo==3">该设备已过保修期</span>	
								<div class="iconBox"><img src="/public/static/mobile/image/rightIcon.png" class="imgs"/></div>
							</div>
							<div class="btns" v-if="activeState1!=0 && activeStateInfo!=2"  v-on:click="navigation('/mobile/warrantystate/index.html?sn='+sn)">设备保修状态<div class="iconBox"><img src="/public/static/mobile/image/rightIcon.png" class="imgs"/></div></div>
							<div class="btns" :class="activeState && activeStateInfo!=2 ? '' : 'disable'" v-on:click="navigationJL('/mobile/maintenanceList/index.html?sn='+sn+'&phone='+phone)">维修记录<div class="iconBox"><img src="/public/static/mobile/image/rightIcon.png" class="imgs"/></div></div>
							<div class="btns" v-if="activeState1!=0 && activeStateInfo!=2" v-on:click="navigationJL('/mobile/download/index.html?sn='+sn)">资料下载<div class="iconBox"><img src="/public/static/mobile/image/rightIcon.png" class="imgs"/></div></div>
						</div>
                        {include file="public/footerbox"}
					</div>
				</div>
				
			</div>
			
            {include file="public/popup"}
			
		</div>

	
<script type = "text/javascript">
	var real_sn="{$real_sn}";
	new Vue({
	  	el: '#index',
	  	data: function () {
		  	return {
				activeBtnText:"保修激活",
		  		showstate:false,  //提示窗
		  		toastMsg:"",   //提示窗的文字
		  		winHeight:document.documentElement.clientHeight+"px",
				activeState:false,  //是否已经激活
				activeState1:0,   //未激活
				activeStateInfo:0,  //激活状态
				sn:"",
				real_sn:real_sn,
				type:"",
				phone:"",
		  	}
	  	},
		// 创建页面
		created(){
			var _this=this;
			// 获取上一页面的参数
			var texts = decodeURI(window.location.href.split("?")[1]);
			var sn = decodeURI(texts.split("&")[0]);
			var type = decodeURI(texts.split("&")[1]);
			var phone = decodeURI(texts.split("&")[2]);
			_this.sn=sn.slice(3);
			_this.type=type.slice(5);
			_this.phone=phone.slice(6);
			// 获取激活状态
			_this.getData();
			
		},
	  	//页面加载需要执行的方法
	  	mounted:function(){
			var _this=this;
			if(_this.type==2){
				location.reload();
				window.history.go(-2);
				// location.href="/mobile/index/index.html?sn="+_this.sn+"&type=1";
				// window.history.back(-2);
			}
			_this.getData();
        },
	  
	  	methods: {
			//   返回
			goBack(){
				console.log("AA")
				window.history.back(-1); 
			},
			//   刷新按钮
			refreshBtn(){
				location.reload();
			},
			
			getData(){
				// alert("AAA")
				// location.reload();
				var _this=this;
				axios.get('/api/mobile/getActive', {
				params: { sn: _this.sn }
			})
			.then(function (res) {
				console.log(res);
				if(res.data.status==1){
					var status1=res.data.status;
					if(status1==0){
						_this.activeState=false;
						_this.activeState1=0;   //未激活
					}else if(status1==1){
						_this.activeState1=1;   //未激活
						var status2=res.data.info;
						_this.activeStateInfo=res.data.info;
						if(status2==0){
							_this.activeState=false;   //激活失败
						}else if(status2==1){    //激活成功
							_this.activeState=true;
						}else if(status2==2){   //审核中
							_this.activeState=true;
						}else if(status2==3){   //已过期
							_this.activeState=true;
						}
					}
					}else{
					// _this.popup(res.data.msg);
					}
				}).catch(function (error) {
					console.log(error);
				});
			},
	  		//页面跳转
	  		navigation:function(url){
				var _this=this;
				// console.log(_this.activeState)
				console.log(url);
				location.href=url;
	  		},
			//   维修记录
			navigationJL:function(url){
				var _this=this;
				// console.log(_this.activeState)
				if(_this.activeState1==0){
					_this.popup("该设备未激活~");
				}else  if(_this.activeStateInfo==2){
					_this.popup("该设备正在审核中~");
				}else{
					if(_this.activeState){
						// console.log(url);
						location.href=url;
					}
				}
				
			},
	  		//弹窗
	  		popup:function(msg){
	  			var _this=this;
	  			_this.toastMsg=msg;
	  			_this.showstate=true;
	  			setTimeout(()=>{
			        _this.showstate=false;
			    },1500);
	  		},
	  		//保修激活按钮
	  		activationBtn:function(url){
	  			var _this=this;
	  			if(_this.activeState){
					if(_this.activeStateInfo==2){
						_this.popup("该设备激活审核中~");
					}else if(_this.activeStateInfo==1){
						_this.popup("该设备已激活成功~");
					}else if(_this.activeStateInfo==3){
						_this.popup("该设备已过期~");
					}
	  			}else{
	  				location.href=url;
	  			}
	  		},
	  		
	  	},
	})
</script>
{include file="public/footer"}

